import request from '@/utils/request'

/**
 *获取用户列表
 */
export async function getPeople (params) {
  const options = {
    params: params
  }
  return await request('/admin/users', options)
}

/**
 * 添加用户
 */
export const addPerson = async (data) => {
  const options = {
    data
  }
  return request.post('/admin/users', options)
}

/**
 * 获取用户详情
 */
export const getUserDetail = async (uid) => {
  return request(`/admin/users/${uid}?include=roles,section`)
}

/**
 * 禁用和启用用户
 */
export const changePermission = async (uid) => {
  return request.delete(`/admin/users/${uid}`)
}

/**
 * 获取所有角色的列表
 */
export const getRoles = async () => {
  return request('/admin/roles')
}

/**
 * 执行修改用户
 */
export const updateUser = async (data) => {
  return request.put(`/admin/users/${data.id}`, { data })
}
/**
 * 重置密码
 */
export const setNewCode = async (data) => {
  return request.patch(`/admin/users/${data.id}/password`, { data })
}
/**
 * 模板的下载
 */
export const templateDownload = () => {
  return request('/admin/users/export', {
    headers: {
      'biz-source-param': 'BLG'
    },
    responseType: 'blob',
  })
}
/**
 * 批量导入
 */
export const manyImp = async (file) => {
  return request.post('/admin/users/import', {
    params: file
  })
}
